<template>

  <el-dropdown>
    <div>
      <svg-icon style="font-size: 20px;color:#fff;" class="icon" icon-class="language" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item :disabled="$i18n.locale==='zh'" @click.native="changeLang('zh')">中文</el-dropdown-item>
        <el-dropdown-item :disabled="$i18n.locale==='en'" @click.native="changeLang('en')">en</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>

</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    changeLang(str) {
      this.$i18n.locale = str
      jsCookie.set('lang', str)
      // 让js重新运行一次就可以了，刷新整个网站
      //   this.$router.go(负数，正数，0)
      //   负数：后退
      //   正数：前进
      //   0：刷新
      this.$router.go(0)
    //   this.$router.back()
    }
  }
}
</script>
<style>
</style>
